// $ANTLR 3.0.1 C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g 2008-05-10 15:28:15

package edu.calvin.djs32.cs214.interpreters.frontend;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

@SuppressWarnings("all")
public class Hobbes2008Parser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "TUPLE", "APPLICATION", "IF", "ELSE", "THEN", "END", "LET", "IN", "KEYWORD", "LETFUNC", "NUMBER", "HEXDIGIT", "SIGN", "INTEGER", "IDENTIFIER", "WHITESPACE", "COMMENTS", "STRING", "COMMA", "LPAREN", "RPAREN"
    };
    public static final int SIGN=16;
    public static final int INTEGER=17;
    public static final int KEYWORD=12;
    public static final int APPLICATION=5;
    public static final int ELSE=7;
    public static final int NUMBER=14;
    public static final int WHITESPACE=19;
    public static final int LETFUNC=13;
    public static final int EOF=-1;
    public static final int LPAREN=23;
    public static final int IF=6;
    public static final int RPAREN=24;
    public static final int TUPLE=4;
    public static final int THEN=8;
    public static final int IN=11;
    public static final int COMMENTS=20;
    public static final int COMMA=22;
    public static final int IDENTIFIER=18;
    public static final int END=9;
    public static final int LET=10;
    public static final int STRING=21;
    public static final int HEXDIGIT=15;

        public Hobbes2008Parser(TokenStream input) {
            super(input);
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return tokenNames; }
    public String getGrammarFileName() { return "C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g"; }

     
      protected void mismatch(IntStream input, int ttype, BitSet follow) 
        throws RecognitionException { 
        throw new MismatchedTokenException(ttype, input); 
      } 
      public void recoverFromMismatchedSet(IntStream input, RecognitionException e, BitSet follow) 
        throws RecognitionException { 
        throw e; 
      } 


    public static class program_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start program
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:58:1: program : expression EOF ;
    public final program_return program() throws RecognitionException {
        program_return retval = new program_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token EOF2=null;
        expression_return expression1 = null;


        Object EOF2_tree=null;

        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:58:8: ( expression EOF )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:58:10: expression EOF
            {
            root_0 = (Object)adaptor.nil();

            pushFollow(FOLLOW_expression_in_program134);
            expression1=expression();
            _fsp--;

            adaptor.addChild(root_0, expression1.getTree());
            EOF2=(Token)input.LT(1);
            match(input,EOF,FOLLOW_EOF_in_program136); 

            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end program

    public static class expression_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start expression
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:1: expression : ( INTEGER | STRING | tuple | application | ife | identifier | let | letfunc );
    public final expression_return expression() throws RecognitionException {
        expression_return retval = new expression_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token INTEGER3=null;
        Token STRING4=null;
        tuple_return tuple5 = null;

        application_return application6 = null;

        ife_return ife7 = null;

        identifier_return identifier8 = null;

        let_return let9 = null;

        letfunc_return letfunc10 = null;


        Object INTEGER3_tree=null;
        Object STRING4_tree=null;

        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:13: ( INTEGER | STRING | tuple | application | ife | identifier | let | letfunc )
            int alt1=8;
            switch ( input.LA(1) ) {
            case INTEGER:
                {
                alt1=1;
                }
                break;
            case STRING:
                {
                alt1=2;
                }
                break;
            case LPAREN:
                {
                alt1=3;
                }
                break;
            case IDENTIFIER:
                {
                int LA1_4 = input.LA(2);

                if ( (LA1_4==LPAREN) ) {
                    alt1=4;
                }
                else if ( (LA1_4==EOF||(LA1_4>=ELSE && LA1_4<=END)||LA1_4==IN||LA1_4==COMMA||LA1_4==RPAREN) ) {
                    alt1=6;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("87:1: expression : ( INTEGER | STRING | tuple | application | ife | identifier | let | letfunc );", 1, 4, input);

                    throw nvae;
                }
                }
                break;
            case IF:
                {
                alt1=5;
                }
                break;
            case LET:
                {
                alt1=7;
                }
                break;
            case LETFUNC:
                {
                alt1=8;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("87:1: expression : ( INTEGER | STRING | tuple | application | ife | identifier | let | letfunc );", 1, 0, input);

                throw nvae;
            }

            switch (alt1) {
                case 1 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:21: INTEGER
                    {
                    root_0 = (Object)adaptor.nil();

                    INTEGER3=(Token)input.LT(1);
                    match(input,INTEGER,FOLLOW_INTEGER_in_expression503); 
                    INTEGER3_tree = (Object)adaptor.create(INTEGER3);
                    adaptor.addChild(root_0, INTEGER3_tree);


                    }
                    break;
                case 2 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:31: STRING
                    {
                    root_0 = (Object)adaptor.nil();

                    STRING4=(Token)input.LT(1);
                    match(input,STRING,FOLLOW_STRING_in_expression507); 
                    STRING4_tree = (Object)adaptor.create(STRING4);
                    adaptor.addChild(root_0, STRING4_tree);


                    }
                    break;
                case 3 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:40: tuple
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_tuple_in_expression511);
                    tuple5=tuple();
                    _fsp--;

                    adaptor.addChild(root_0, tuple5.getTree());

                    }
                    break;
                case 4 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:48: application
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_application_in_expression515);
                    application6=application();
                    _fsp--;

                    adaptor.addChild(root_0, application6.getTree());

                    }
                    break;
                case 5 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:62: ife
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_ife_in_expression519);
                    ife7=ife();
                    _fsp--;

                    adaptor.addChild(root_0, ife7.getTree());

                    }
                    break;
                case 6 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:68: identifier
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_identifier_in_expression523);
                    identifier8=identifier();
                    _fsp--;

                    adaptor.addChild(root_0, identifier8.getTree());

                    }
                    break;
                case 7 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:81: let
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_let_in_expression527);
                    let9=let();
                    _fsp--;

                    adaptor.addChild(root_0, let9.getTree());

                    }
                    break;
                case 8 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:87:87: letfunc
                    {
                    root_0 = (Object)adaptor.nil();

                    pushFollow(FOLLOW_letfunc_in_expression531);
                    letfunc10=letfunc();
                    _fsp--;

                    adaptor.addChild(root_0, letfunc10.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end expression

    public static class application_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start application
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:88:1: application : identifier tuple -> ^( APPLICATION identifier tuple ) ;
    public final application_return application() throws RecognitionException {
        application_return retval = new application_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        identifier_return identifier11 = null;

        tuple_return tuple12 = null;


        RewriteRuleSubtreeStream stream_tuple=new RewriteRuleSubtreeStream(adaptor,"rule tuple");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:88:13: ( identifier tuple -> ^( APPLICATION identifier tuple ) )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:88:15: identifier tuple
            {
            pushFollow(FOLLOW_identifier_in_application538);
            identifier11=identifier();
            _fsp--;

            stream_identifier.add(identifier11.getTree());
            pushFollow(FOLLOW_tuple_in_application540);
            tuple12=tuple();
            _fsp--;

            stream_tuple.add(tuple12.getTree());

            // AST REWRITE
            // elements: identifier, tuple
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 88:32: -> ^( APPLICATION identifier tuple )
            {
                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:88:35: ^( APPLICATION identifier tuple )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(adaptor.create(APPLICATION, "APPLICATION"), root_1);

                adaptor.addChild(root_1, stream_identifier.next());
                adaptor.addChild(root_1, stream_tuple.next());

                adaptor.addChild(root_0, root_1);
                }

            }



            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end application

    public static class identifier_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start identifier
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:89:1: identifier : IDENTIFIER ;
    public final identifier_return identifier() throws RecognitionException {
        identifier_return retval = new identifier_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token IDENTIFIER13=null;

        Object IDENTIFIER13_tree=null;

        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:89:12: ( IDENTIFIER )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:89:14: IDENTIFIER
            {
            root_0 = (Object)adaptor.nil();

            IDENTIFIER13=(Token)input.LT(1);
            match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_identifier557); 
            IDENTIFIER13_tree = (Object)adaptor.create(IDENTIFIER13);
            adaptor.addChild(root_0, IDENTIFIER13_tree);


            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end identifier

    public static class let_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start let
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:90:1: let : LET identifier KEYWORD expression IN expression -> ^( LET identifier expression expression ) ;
    public final let_return let() throws RecognitionException {
        let_return retval = new let_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LET14=null;
        Token KEYWORD16=null;
        Token IN18=null;
        identifier_return identifier15 = null;

        expression_return expression17 = null;

        expression_return expression19 = null;


        Object LET14_tree=null;
        Object KEYWORD16_tree=null;
        Object IN18_tree=null;
        RewriteRuleTokenStream stream_KEYWORD=new RewriteRuleTokenStream(adaptor,"token KEYWORD");
        RewriteRuleTokenStream stream_IN=new RewriteRuleTokenStream(adaptor,"token IN");
        RewriteRuleTokenStream stream_LET=new RewriteRuleTokenStream(adaptor,"token LET");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:90:6: ( LET identifier KEYWORD expression IN expression -> ^( LET identifier expression expression ) )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:90:8: LET identifier KEYWORD expression IN expression
            {
            LET14=(Token)input.LT(1);
            match(input,LET,FOLLOW_LET_in_let565); 
            stream_LET.add(LET14);

            pushFollow(FOLLOW_identifier_in_let567);
            identifier15=identifier();
            _fsp--;

            stream_identifier.add(identifier15.getTree());
            KEYWORD16=(Token)input.LT(1);
            match(input,KEYWORD,FOLLOW_KEYWORD_in_let569); 
            stream_KEYWORD.add(KEYWORD16);

            pushFollow(FOLLOW_expression_in_let571);
            expression17=expression();
            _fsp--;

            stream_expression.add(expression17.getTree());
            IN18=(Token)input.LT(1);
            match(input,IN,FOLLOW_IN_in_let573); 
            stream_IN.add(IN18);

            pushFollow(FOLLOW_expression_in_let575);
            expression19=expression();
            _fsp--;

            stream_expression.add(expression19.getTree());

            // AST REWRITE
            // elements: identifier, expression, LET, expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 90:56: -> ^( LET identifier expression expression )
            {
                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:90:59: ^( LET identifier expression expression )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_LET.next(), root_1);

                adaptor.addChild(root_1, stream_identifier.next());
                adaptor.addChild(root_1, stream_expression.next());
                adaptor.addChild(root_1, stream_expression.next());

                adaptor.addChild(root_0, root_1);
                }

            }



            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end let

    public static class ife_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start ife
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:91:1: ife : IF expression THEN expression ELSE expression END -> ^( IF ( expression )* ) ;
    public final ife_return ife() throws RecognitionException {
        ife_return retval = new ife_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token IF20=null;
        Token THEN22=null;
        Token ELSE24=null;
        Token END26=null;
        expression_return expression21 = null;

        expression_return expression23 = null;

        expression_return expression25 = null;


        Object IF20_tree=null;
        Object THEN22_tree=null;
        Object ELSE24_tree=null;
        Object END26_tree=null;
        RewriteRuleTokenStream stream_THEN=new RewriteRuleTokenStream(adaptor,"token THEN");
        RewriteRuleTokenStream stream_END=new RewriteRuleTokenStream(adaptor,"token END");
        RewriteRuleTokenStream stream_IF=new RewriteRuleTokenStream(adaptor,"token IF");
        RewriteRuleTokenStream stream_ELSE=new RewriteRuleTokenStream(adaptor,"token ELSE");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:91:6: ( IF expression THEN expression ELSE expression END -> ^( IF ( expression )* ) )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:91:8: IF expression THEN expression ELSE expression END
            {
            IF20=(Token)input.LT(1);
            match(input,IF,FOLLOW_IF_in_ife595); 
            stream_IF.add(IF20);

            pushFollow(FOLLOW_expression_in_ife597);
            expression21=expression();
            _fsp--;

            stream_expression.add(expression21.getTree());
            THEN22=(Token)input.LT(1);
            match(input,THEN,FOLLOW_THEN_in_ife599); 
            stream_THEN.add(THEN22);

            pushFollow(FOLLOW_expression_in_ife601);
            expression23=expression();
            _fsp--;

            stream_expression.add(expression23.getTree());
            ELSE24=(Token)input.LT(1);
            match(input,ELSE,FOLLOW_ELSE_in_ife603); 
            stream_ELSE.add(ELSE24);

            pushFollow(FOLLOW_expression_in_ife605);
            expression25=expression();
            _fsp--;

            stream_expression.add(expression25.getTree());
            END26=(Token)input.LT(1);
            match(input,END,FOLLOW_END_in_ife607); 
            stream_END.add(END26);


            // AST REWRITE
            // elements: expression, IF
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 91:58: -> ^( IF ( expression )* )
            {
                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:91:61: ^( IF ( expression )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_IF.next(), root_1);

                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:91:66: ( expression )*
                while ( stream_expression.hasNext() ) {
                    adaptor.addChild(root_1, stream_expression.next());

                }
                stream_expression.reset();

                adaptor.addChild(root_0, root_1);
                }

            }



            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end ife

    public static class tuple_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start tuple
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:1: tuple : LPAREN ( expression ( COMMA expression )* )? RPAREN -> ^( TUPLE ( expression )* ) ;
    public final tuple_return tuple() throws RecognitionException {
        tuple_return retval = new tuple_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LPAREN27=null;
        Token COMMA29=null;
        Token RPAREN31=null;
        expression_return expression28 = null;

        expression_return expression30 = null;


        Object LPAREN27_tree=null;
        Object COMMA29_tree=null;
        Object RPAREN31_tree=null;
        RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_COMMA=new RewriteRuleTokenStream(adaptor,"token COMMA");
        RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:8: ( LPAREN ( expression ( COMMA expression )* )? RPAREN -> ^( TUPLE ( expression )* ) )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:10: LPAREN ( expression ( COMMA expression )* )? RPAREN
            {
            LPAREN27=(Token)input.LT(1);
            match(input,LPAREN,FOLLOW_LPAREN_in_tuple624); 
            stream_LPAREN.add(LPAREN27);

            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:17: ( expression ( COMMA expression )* )?
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==IF||LA3_0==LET||LA3_0==LETFUNC||(LA3_0>=INTEGER && LA3_0<=IDENTIFIER)||LA3_0==STRING||LA3_0==LPAREN) ) {
                alt3=1;
            }
            switch (alt3) {
                case 1 :
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:18: expression ( COMMA expression )*
                    {
                    pushFollow(FOLLOW_expression_in_tuple627);
                    expression28=expression();
                    _fsp--;

                    stream_expression.add(expression28.getTree());
                    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:29: ( COMMA expression )*
                    loop2:
                    do {
                        int alt2=2;
                        int LA2_0 = input.LA(1);

                        if ( (LA2_0==COMMA) ) {
                            alt2=1;
                        }


                        switch (alt2) {
                    	case 1 :
                    	    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:30: COMMA expression
                    	    {
                    	    COMMA29=(Token)input.LT(1);
                    	    match(input,COMMA,FOLLOW_COMMA_in_tuple630); 
                    	    stream_COMMA.add(COMMA29);

                    	    pushFollow(FOLLOW_expression_in_tuple632);
                    	    expression30=expression();
                    	    _fsp--;

                    	    stream_expression.add(expression30.getTree());

                    	    }
                    	    break;

                    	default :
                    	    break loop2;
                        }
                    } while (true);


                    }
                    break;

            }

            RPAREN31=(Token)input.LT(1);
            match(input,RPAREN,FOLLOW_RPAREN_in_tuple638); 
            stream_RPAREN.add(RPAREN31);


            // AST REWRITE
            // elements: expression
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 92:58: -> ^( TUPLE ( expression )* )
            {
                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:61: ^( TUPLE ( expression )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(adaptor.create(TUPLE, "TUPLE"), root_1);

                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:92:69: ( expression )*
                while ( stream_expression.hasNext() ) {
                    adaptor.addChild(root_1, stream_expression.next());

                }
                stream_expression.reset();

                adaptor.addChild(root_0, root_1);
                }

            }



            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end tuple

    public static class letfunc_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start letfunc
    // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:93:1: letfunc : LETFUNC identifier identifier KEYWORD expression IN expression -> ^( LETFUNC identifier identifier expression expression ) ;
    public final letfunc_return letfunc() throws RecognitionException {
        letfunc_return retval = new letfunc_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token LETFUNC32=null;
        Token KEYWORD35=null;
        Token IN37=null;
        identifier_return identifier33 = null;

        identifier_return identifier34 = null;

        expression_return expression36 = null;

        expression_return expression38 = null;


        Object LETFUNC32_tree=null;
        Object KEYWORD35_tree=null;
        Object IN37_tree=null;
        RewriteRuleTokenStream stream_LETFUNC=new RewriteRuleTokenStream(adaptor,"token LETFUNC");
        RewriteRuleTokenStream stream_KEYWORD=new RewriteRuleTokenStream(adaptor,"token KEYWORD");
        RewriteRuleTokenStream stream_IN=new RewriteRuleTokenStream(adaptor,"token IN");
        RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_identifier=new RewriteRuleSubtreeStream(adaptor,"rule identifier");
        try {
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:93:10: ( LETFUNC identifier identifier KEYWORD expression IN expression -> ^( LETFUNC identifier identifier expression expression ) )
            // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:93:12: LETFUNC identifier identifier KEYWORD expression IN expression
            {
            LETFUNC32=(Token)input.LT(1);
            match(input,LETFUNC,FOLLOW_LETFUNC_in_letfunc657); 
            stream_LETFUNC.add(LETFUNC32);

            pushFollow(FOLLOW_identifier_in_letfunc659);
            identifier33=identifier();
            _fsp--;

            stream_identifier.add(identifier33.getTree());
            pushFollow(FOLLOW_identifier_in_letfunc661);
            identifier34=identifier();
            _fsp--;

            stream_identifier.add(identifier34.getTree());
            KEYWORD35=(Token)input.LT(1);
            match(input,KEYWORD,FOLLOW_KEYWORD_in_letfunc663); 
            stream_KEYWORD.add(KEYWORD35);

            pushFollow(FOLLOW_expression_in_letfunc665);
            expression36=expression();
            _fsp--;

            stream_expression.add(expression36.getTree());
            IN37=(Token)input.LT(1);
            match(input,IN,FOLLOW_IN_in_letfunc667); 
            stream_IN.add(IN37);

            pushFollow(FOLLOW_expression_in_letfunc669);
            expression38=expression();
            _fsp--;

            stream_expression.add(expression38.getTree());

            // AST REWRITE
            // elements: identifier, identifier, expression, expression, LETFUNC
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"token retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 93:75: -> ^( LETFUNC identifier identifier expression expression )
            {
                // C:\\Documents and Settings\\Dwight Schrute\\workspace\\cs214\\CS-214-Interpreters\\src\\edu\\calvin\\djs32\\cs214\\interpreters\\frontend\\Hobbes2008.g:93:78: ^( LETFUNC identifier identifier expression expression )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot(stream_LETFUNC.next(), root_1);

                adaptor.addChild(root_1, stream_identifier.next());
                adaptor.addChild(root_1, stream_identifier.next());
                adaptor.addChild(root_1, stream_expression.next());
                adaptor.addChild(root_1, stream_expression.next());

                adaptor.addChild(root_0, root_1);
                }

            }



            }

            retval.stop = input.LT(-1);

                retval.tree = (Object)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
         
          catch (RecognitionException e) { 
            throw e; 
          } 
        finally {
        }
        return retval;
    }
    // $ANTLR end letfunc


 

    public static final BitSet FOLLOW_expression_in_program134 = new BitSet(new long[]{0x0000000000000000L});
    public static final BitSet FOLLOW_EOF_in_program136 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INTEGER_in_expression503 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_STRING_in_expression507 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_tuple_in_expression511 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_application_in_expression515 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ife_in_expression519 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_expression523 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_let_in_expression527 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_letfunc_in_expression531 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_application538 = new BitSet(new long[]{0x0000000000800000L});
    public static final BitSet FOLLOW_tuple_in_application540 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_identifier557 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LET_in_let565 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_identifier_in_let567 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_KEYWORD_in_let569 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_let571 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_IN_in_let573 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_let575 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IF_in_ife595 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_ife597 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_THEN_in_ife599 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_ife601 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_ELSE_in_ife603 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_ife605 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_END_in_ife607 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LPAREN_in_tuple624 = new BitSet(new long[]{0x0000000001A62440L});
    public static final BitSet FOLLOW_expression_in_tuple627 = new BitSet(new long[]{0x0000000001400000L});
    public static final BitSet FOLLOW_COMMA_in_tuple630 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_tuple632 = new BitSet(new long[]{0x0000000001400000L});
    public static final BitSet FOLLOW_RPAREN_in_tuple638 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LETFUNC_in_letfunc657 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_identifier_in_letfunc659 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_identifier_in_letfunc661 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_KEYWORD_in_letfunc663 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_letfunc665 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_IN_in_letfunc667 = new BitSet(new long[]{0x0000000000A62440L});
    public static final BitSet FOLLOW_expression_in_letfunc669 = new BitSet(new long[]{0x0000000000000002L});

}